﻿<UserControl x:Name="userControl" x:Class="XDCCManager.Controls.ServerList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:Servers="clr-namespace:XDCCManager.Model.Servers"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
	<UserControl.Resources>
		<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
		<DataTemplate x:Key="ServerInfoDataTemplate">
			<StackPanel>
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition SharedSizeGroup="ServerColumnNetwork" Width="Auto"/>
						<ColumnDefinition SharedSizeGroup="ServerColumnHosT" Width="Auto"/>
					</Grid.ColumnDefinitions>
					<TextBlock Text="{Binding Network}"/>
					<TextBlock Text="{Binding Addresses[0].Hostname, Mode=OneWay}" Margin="20,0,0,0" Grid.Column="1"/>
				</Grid>
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition SharedSizeGroup="ServerColumnBotName" Width="Auto"/>
						<ColumnDefinition SharedSizeGroup="ServerColumnNick" Width="Auto"/>
					</Grid.ColumnDefinitions>
					<TextBlock Text="{Binding BotName}" Margin="20,0,0,0"/>
					<TextBlock Text="{Binding Nick}" Margin="20,0,0,0" Grid.Column="1"/>
				</Grid>
			</StackPanel>
		</DataTemplate>
		<DataTemplate DataType="{x:Type Servers:Server}">
			<DockPanel>
				<UniformGrid DockPanel.Dock="Right" Rows="1" Columns="2">
					<Button Content="Edit" VerticalAlignment="Top" Click="Edit_Click"/>
					<Button Content="Connect" VerticalAlignment="Top" Click="Connect_Click"/>
				</UniformGrid>
				<ContentControl Content="{Binding}" ContentTemplate="{DynamicResource ServerInfoDataTemplate}"/>
			</DockPanel>
		</DataTemplate>
	</UserControl.Resources>
    <Grid DataContext="{DynamicResource ServerContextDataSource}" Grid.IsSharedSizeScope="True">
    	<Grid.RowDefinitions>
    		<RowDefinition Height="Auto"/>
    		<RowDefinition/>
    		<RowDefinition Height="Auto"/>
    	</Grid.RowDefinitions>
    	<GroupBox Header="Current server" DataContext="{Binding CurrentServer}" Visibility="{Binding ShowCurrent, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=userControl}">
    		<ContentControl Content="{Binding}" ContentTemplate="{DynamicResource ServerInfoDataTemplate}" Height="31.92"/>
    	</GroupBox>
    	<ListBox Grid.Row="1" ItemsSource="{Binding Servers}" HorizontalContentAlignment="Stretch"/>
    	<UniformGrid HorizontalAlignment="Right" Grid.Row="2" Rows="1" >
    		<Button Content="Add" Click="Add_Click"/>
    		<Button Content="Close" Click="Close_Click" Visibility="{Binding ShowClose, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=userControl}"/>
    	</UniformGrid>
            
    </Grid>
</UserControl>
